<?php
namespace app\web\model;

use app\web\model\Config;
use think\facade\Log;
use app\web\model\CouponType;
/**
 * @package app\basic\model
 */
class Coupon extends Common 
{



	
	/**
	 * 使用优惠券
	 * [useCoupon description]
	 * @param  [type] $id [description]
	 * @return [type]     [description]
	 */
	public static function useCoupon($id){
		$coupon = self::get($id);
		$coupon->status = 1;
		$coupon->use_time = time();
		if($coupon->save()) return true;
		return false;
	}
	/**
	 * 取消订单退后优惠券
	 * [returnCoupon description]
	 * @param  [type] $id [description]
	 * @return [type]     [description]
	 */
	public static function returnCoupon($id){
		$coupon = self::get($id);
		$coupon->status = 0;
		$coupon->use_time = null;
		$res = $coupon->save();
		return $res ? true : false;
	}

}
